// 顶点着色器
struct VertexInput {
    @location(0) position: vec3f,
    @location(1) color: vec3f,
};

struct VertexOutput {
    @builtin(position) clip_position: vec4f,
    @location(0) color: vec3f,
};

// 相机变换矩阵
@group(0) @binding(0) var<uniform> model: mat4x4f;
@group(0) @binding(1) var<uniform> view: mat4x4f;
@group(0) @binding(2) var<uniform> proj: mat4x4f;

@vertex
fn vs_main(
    model_data: VertexInput,
) -> VertexOutput {
    var out: VertexOutput;
    out.color = model_data.color;
    // 应用模型-视图-投影变换
    out.clip_position = proj * view * model * vec4f(model_data.position, 1.0);
    return out;
}

// 片元着色器

@fragment
fn fs_main(in: VertexOutput) -> @location(0) vec4f {
    return vec4f(in.color, 1.0);
}